<template>
	<view class="pics">
		<scroll-view class="left" scroll-y="true" >
			<view 
			@click="checkItem(index,item.id)"
			:class="active===index?'active':''" 
			v-for="(item,index) in tagList" 
			:key="item.id">{{item.title}}</view>			
		</scroll-view>
		
		<scroll-view scroll-y="true" class="right" >
			<view class="item "v-for="(img,index) in imagesList" :key="index">
				<image :src="img.img_url" mode="" @click="perViewImage(img.img_url)"></image>
				<text>{{img.title}}</text>
				
			</view>
			<text  class="notice" v-if="this.imagesList.length === 0 ? true : false">----暂无数据----</text>
		</scroll-view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tagList:[],
				active:0,
				cateid:0,
				imagesList:[]
				
			}
		},
		onLoad(){
			this.getTagsList()
			
		},
		methods: {
			async getTagsList(){
				 const res =  await this.$myRequest({
					url:'/api/getimgcategory'
				})
				
				this.tagList = res.data.message
				this.checkItem(0,this.tagList[0].id)
				console.log(res);
			},
			async checkItem(index,id){
				this.active = index
				console.log("actice"+this.active);
				this.cateid = id
				
				//获取右侧数据
				const res = await this.$myRequest({
					url:'/api/getimages/'+this.cateid
					
				})
				this.imagesList = res.data.message
				console.log('imaglist'+res);
				
				
			},
			perViewImage(current){
				const urls = this.imagesList.map(item=>{
					return item.img_url
				})
				uni.previewImage({
					current,
					urls,
				})
			}
			
			
		}
	}
</script>

<style lang="scss">
	page{
		height: 100%;
	
	}
	.pics{
		height: 100%;
		display: flex;
		.left{
			width: 200rpx;
			height: 100%;
			border-right:1px solid #eee ;
			view{
				height:50px;
				line-height: 50px;
				color:#333;
				text-align: center;
				border-top:1px solid #eee ;
				
				
			}
			.active{
			background-color: $shop-color;
			color:#fff;
			}
			
		}
		.right{
			width: 530rpx;
			height: 100%;
			margin: 10rpx auto;
			.item{
				width: 530rpx;
				height: 530rpx;
				border-radius: 5px;
			}
			text{
				height: 60rpx;
				font-size: 30rpx;
			}
			.notice{
				width: 530rpx;
				display: block;
				text-align: center;
				line-height: 30px;
				color: #bcbcbc;
			}
		}
	}

</style>
